package view;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import control.MainListener;
import control.util.Util;

import model.Device;

@SuppressWarnings("serial")
public class InfoGUI extends JTabbedPane {
	
	private TabSystemInfo tabSystemInfo;
	private TabIpInfo tabIpInfo;

	public InfoGUI(int width, int height) {
		initObjs(width, height);
		initProperties();
	}
	
	private void initObjs(int width, int height) {
		tabSystemInfo = new TabSystemInfo(width, height);
		tabIpInfo = new TabIpInfo(width, height);
	}
	
	private void initProperties() {
		setBackground(Util.COLOR_BACKGROUND);
		setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
		
		addTab(tabSystemInfo.getTitle(), null, tabSystemInfo, tabSystemInfo.getTooltip());
		addTab(tabIpInfo.getTitle(), null, tabIpInfo, tabIpInfo.getTooltip());
	}
	
	public TabSystemInfo getTabSystemInfo() {
		return tabSystemInfo;
	}
	
	public TabIpInfo getTabIpInfo() {
		return tabIpInfo;
	}
	
	public void addListeners(MainListener listener) {
		tabSystemInfo.addListeners(listener);
		tabIpInfo.addListeners(listener);
	}
	// ****************************** DEVICE ******************************
	public void addDeviceInfo(Device device) {
		tabSystemInfo.addDeviceSystemInfo(device);
		tabIpInfo.addDeviceIpInfo(device);
	}
	
	public static void main(String[] args) {
		JFrame frame = new JFrame("Teste");
		JTabbedPane panel = new InfoGUI(300, 300);
		frame.add(panel);
		// ********** TESTE **********
		((InfoGUI)panel).addDeviceInfo(new Device("10"));
		// ***************************
		frame.pack();
		frame.setPreferredSize(new Dimension(500, 500));
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
	}
}
